var t = require("../export.js");

getApp();

Page({
    data: {
        CarList: [],
        index: -1,
        date: "",
        region: [],
        region1: [],
        buttonIsDisabled: !1,
        submitIsLoading: !1,
        reg: 0,
        reg1: 0,
        index1: -1,
        options: {},
        CarLevelList: []
    },
    onLoad: function(t) {
        this.setData({
            options: t
        }), this.getCarList(t), this.getExplain(t);
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    formSubmit: function(a) {
        var i = this, n = a.detail.value;
        if (-1 != n.car_goods_id) if (-1 != n.car_goods_level_id) {
            n.car_goods_id = this.data.CarList[this.data.index].id, n.car_goods_level_id = this.data.CarLevelList[this.data.index1].id;
            var e = n;
            this.setData({
                submitIsLoading: !0,
                buttonIsDisabled: !0
            }), t.requestUtil.post(t._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Apiform/ershou.html", e, function(t) {
                console.log(t), i.ershou(t);
            }, this, {
                isShowLoading: !1,
                completeAfter: function(t) {
                    this.setData({
                        submitIsLoading: !1,
                        buttonIsDisabled: !1
                    });
                }
            });
        } else t.dg.alert("请选择车型"); else t.dg.alert("请选择车款");
    },
    ershou: function(t) {
        this.setData({
            submitIsLoading: !1,
            buttonIsDisabled: !1
        }), wx.showModal({
            title: "提示",
            content: t.info,
            showCancel: !1,
            complete: function(t) {
                wx.navigateTo({
                    url: "/pages/car/index/index",
                    fail: function(t) {
                        wx.switchTab({
                            url: "/pages/car/index/index"
                        });
                    }
                });
            }
        });
    },
    getCarList: function(a) {
        var i = this;
        t.requestUtil.post(t._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Api/getCarList.html", a, function(t) {
            i.setData({
                CarList: t
            });
        });
    },
    getExplain: function(a) {
        var i = this;
        t.requestUtil.post(t._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Api/getExplain.html", a, function(t) {
            console.log(t), i.setData({
                Explain: t.explain,
                coupon: t.coupon,
                Exlength: t.explain.zhihuan_explain.length
            });
        });
    },
    bindPickerChange: function(a) {
        var i = this, n = a.detail.value;
        this.setData({
            index: n
        });
        var e = this.data.CarList[n].id, o = this.data.options;
        o.car_goods_id = e, t.requestUtil.post(t._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Api/getCarLevelList.html", o, function(t) {
            i.setData({
                CarLevelList: t
            });
        });
    },
    bindPickerChange1: function(t) {
        var a = t.detail.value;
        this.setData({
            index1: a
        });
    },
    ChangeDate: function(t) {
        this.setData({
            date: t.detail.value
        });
    },
    bindRegionChange: function(t) {
        this.setData({
            region: t.detail.value,
            reg: 1
        });
    },
    bindRegionChange1: function(t) {
        this.setData({
            region1: t.detail.value,
            reg1: 1
        });
    },
    goCoupon: function() {
        wx.navigateTo({
            url: "/pages/car/get-coupon/get-coupon"
        });
    }
});